<template>
    <div class="home">
        <el-container>
            <!-- 页面头部 -->
            <el-header>
                <div class="header_content flex_row justify_content_between">
                    <div class="flex_row">
                        <div class>
                            <el-select
                                v-model="value"
                                placeholder="请选择验证类型"
                                @change="VerificationOptions"
                            >
                                <el-option
                                    v-for="item in cities"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id"
                                >
                                    <div class="flex_row justify_content_between">
                                        <span>{{ item.name }}</span>
                                    </div>
                                </el-option>
                            </el-select>
                        </div>
                        <div class="reset_pwd">
                            <el-button plain @click="centerDialogVisible = true">修改密码</el-button>
                        </div>
                        <div class="reset_pwd">
                            <el-button plain @click="NicknameDialog = true">修改昵称</el-button>
                        </div>
                        <div class="reset_pwd">
                            <el-popover placement="bottom" width="200" trigger="click">
                                <div class="text_center">
                                    <p>安卓手机扫码下载</p>
                                    <img
                                        src="../../assets/download_code.png"
                                        width="150"
                                        height="150"
                                        alt
                                    />
                                </div>
                                <el-button type="success" slot="reference">安卓APP下载</el-button>
                            </el-popover>
                            <!-- <el-button
                                type="success"
                                plain
                                @click="centerDialogVisible = true"
                            ></el-button>-->
                        </div>
                    </div>
                    <div class="flex_row align_items_center">
                        <el-button
                            type="success"
                            size="mini"
                            v-if="gradeExpireTime == 0 || gradeExpireTime==''"
                            @click="ActivationCodeDialog = true"
                        >激活账号</el-button>
                        <div v-else class="flex_row align_items_center">
                            <el-button
                                type="success"
                                size="mini"
                                @click="ActivationCodeDialog = true"
                            >续租</el-button>
                            <div>会员到期时间：{{gradeExpireTime}}</div>
                        </div>
                        <el-button
                            type="danger"
                            size="mini"
                            style="margin-left:20px;"
                            @click="Logout"
                            :loading="btnLoading"
                        >退出登录</el-button>
                    </div>
                </div>
            </el-header>
            <!-- 页面头部 end -->
            <el-main>
                <div class="home_main">
                    <div class="bulletin_box flex_row align_items_center justify_content_between">
                        <div class="flex_row align_items_center">
                            <div>
                                公告
                                <img
                                    class="bulletin_icon"
                                    src="../../assets/bulletin_icon.png"
                                    alt
                                /> ：
                            </div>
                            <vue-seamless-scroll
                                :data="newsList"
                                :class-option="optionLeft"
                                class="seamless-warp2"
                                v-if="newsList.length>0"
                            >
                                <ul class="item flex_row align_items_center">
                                    <li
                                        v-for="(item,index) in newsList"
                                        v-text="item.title"
                                        :key="index"
                                    ></li>
                                </ul>
                            </vue-seamless-scroll>
                        </div>
                        <div style="color:#f56c6c;">开奖后,记录更新预计5-30分钟</div>
                    </div>
                    <div class="home_main_content">
                        <div class="flex_row">
                            <div class="flex_column" style="width:20%">
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="IsSelFormula=true;showDrawer(1);"
                                >收藏列表</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="IsSelFormula=false;showDrawer(3)"
                                >精选公式</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="IsSelFormula=false;showDrawer(2);"
                                >师傅公式</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="$router.push('/mentor')"
                                >师徒</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="toRecord"
                                >开奖记录</el-button>
                                <el-dropdown @command="dropDownClick" placement="bottom-start">
                                    <el-button type="primary" class="operate_btn" plain>
                                        功能说明
                                        <i class="el-icon-arrow-down el-icon--right"></i>
                                    </el-button>
                                    <el-dropdown-menu slot="dropdown" class="my_dropdown_menu">
                                        <el-dropdown-item
                                            v-for="(item,index) in CourseListData"
                                            :key="item.id"
                                            :command="index"
                                        >{{item.name}}</el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    v-clipboard:copy="formulaVerification"
                                    v-clipboard:success="onCopy"
                                    v-clipboard:error="onError"
                                    :disabled="formulaVerification == ''"
                                >复制公式</el-button>
                            </div>
                            <div class="formula_textarea">
                                <el-input
                                    type="textarea"
                                    :rows="17"
                                    placeholder="请在这里输入公式"
                                    v-model="formulaVerification"
                                    @input="FormulaEnter"
                                    :disabled="gradeExpireTime == 0"
                                    class="formula_input"
                                    style
                                ></el-input>
                            </div>
                        </div>
                        <div class="flex_row justify_content_center verification_btn_box">
                            <el-button
                                type="primary"
                                class="verification_btn"
                                :disabled="formulaVerification == '' || loading"
                                @click="ReferFormulaVerification()"
                            >验证公式</el-button>
                        </div>
                        <div class="flex_row">
                            <div class="flex_column" style="width:20%">
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    :loading="btnLoading"
                                    :disabled="formulaVerification==''"
                                    @click="Refresh"
                                >清空</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    :disabled="formulaTextarea==''"
                                    :loading="btnLoading"
                                    @click="VerifyCollect"
                                >收藏</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    @click="stickyOrEnd"
                                >到底/顶</el-button>
                                <el-button
                                    type="primary"
                                    plain
                                    class="operate_btn"
                                    v-clipboard:copy="copyTxt"
                                    v-clipboard:success="onCopy"
                                    v-clipboard:error="onError"
                                    :disabled="formulaTextarea==''"
                                >复制结果</el-button>
                            </div>
                            <div
                                class="formula_textarea"
                                v-loading="loading"
                                element-loading-text="公式验证中，请稍等。。。"
                                element-loading-spinner="el-icon-loading"
                            >
                                <el-input
                                    type="textarea"
                                    disabled
                                    :rows="20"
                                    placeholder="验证结果区"
                                    v-model="formulaTextarea"
                                    v-show="formulaTextarea==''"
                                    style="text-align: left;"
                                ></el-input>
                                <div
                                    v-html="formulaTextarea"
                                    ref="copy"
                                    style="white-space: pre-line;text-align: left;max-height:400px;overflow-y: auto;"
                                    :style="{maxHeight:fullWidth<981?'1000px':'500px'}"
                                    class="result"
                                    v-show="formulaTextarea"
                                    disabled
                                ></div>
                            </div>
                        </div>
                    </div>
                </div>
            </el-main>
        </el-container>
        <!-- 修改密码提示框 -->
        <el-dialog
            title="修改密码"
            :visible.sync="centerDialogVisible"
            width="300px"
            center
            @close="clearInputVal"
        >
            <div>
                <el-input
                    placeholder="请输入原密码"
                    v-model="oldPwd"
                    clearable
                    style="margin:10px 0;"
                    type="password"
                ></el-input>
                <el-input
                    placeholder="请输入新密码"
                    v-model="newPwd"
                    clearable
                    style="margin:10px 0;"
                    type="password"
                ></el-input>
                <el-input
                    placeholder="请确认密码"
                    v-model="confirmPwd"
                    clearable
                    style="margin:10px 0;"
                    type="password"
                ></el-input>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="SubmitPassword" :loading="btnLoading">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 修改密码提示框  end-->
        <!-- 收藏列表 -->
        <el-drawer
            :title="IsFeatured?'精选公式':IsSelFormula?'收藏列表':'师傅的公式'"
            :visible.sync="drawer"
            :direction="direction"
            @close="btnLoading =false;"
        >
            <div
                class="drawer_content"
                v-loading="btnLoading"
                element-loading-text="拼命加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.8)"
            >
                <div class="select_options flex_row justify_content_center">
                    <el-select
                        v-model="drawerValue"
                        placeholder="请选择验证类型"
                        @change="DrawerSelectChange"
                    >
                        <el-option
                            v-for="item in cities"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                        >
                            <div class="flex_row justify_content_between">
                                <span>{{ item.name }}</span>
                            </div>
                        </el-option>
                    </el-select>
                </div>
                <div>
                    <ul class="forks_ul" v-if="collectionListData.length>0">
                        <li
                            class="flex_row align_items_center justify_content_between"
                            v-for="(item,index) in collectionListData"
                            :key="index"
                        >
                            <div class style="width:60%;">
                                <div
                                    class="list_title"
                                    @click="TestAndVerify(index)"
                                >{{item.show_formula}}</div>
                                <div class="list_date">{{item.collect_time}}</div>
                            </div>
                            <div v-if="IsSelFormula">
                                <el-popover placement="top" width="200">
                                    <div class="popover_box flex_column">
                                        <el-input v-model="Remarks" placeholder="请输入备注名称"></el-input>
                                        <el-button
                                            type="success"
                                            size="mini"
                                            style="margin-top:20px;"
                                            @click="UpRemaker(index)"
                                        >提交</el-button>
                                    </div>
                                    <el-button
                                        type="primary"
                                        icon="el-icon-edit"
                                        circle
                                        size="mini"
                                        style="margin-right:15px;"
                                        slot="reference"
                                    ></el-button>
                                </el-popover>

                                <el-popconfirm
                                    confirmButtonText="好的"
                                    cancelButtonText="我想想"
                                    confirmButtonType="danger"
                                    icon="el-icon-info"
                                    iconColor="red"
                                    title="确定删除记录？"
                                    @onConfirm="DelForks(index)"
                                >
                                    <el-button
                                        type="danger"
                                        icon="el-icon-delete"
                                        circle
                                        size="mini"
                                        slot="reference"
                                    ></el-button>
                                </el-popconfirm>
                            </div>
                        </li>
                    </ul>
                    <div v-else class="text_center" style="color:#C0C4CC;">暂无数据</div>
                </div>
                <div
                    class="flex_row align_items_center justify_content_center"
                    style="margin-top:36px;"
                >
                    <el-pagination
                        background
                        layout="prev, pager, next"
                        :total="collectionListMeta.total"
                        :pager-count="15"
                        :small="true"
                        @current-change="PaginationChange"
                    ></el-pagination>
                </div>
            </div>
        </el-drawer>
        <!-- 收藏列表 end -->
        <!-- 激活账号 -->
        <el-dialog
            title="账号激活"
            :visible.sync="ActivationCodeDialog"
            width="300px"
            center
            @close="clearInputVal"
        >
            <div>
                <el-input placeholder="请输入激活码" v-model="ActivationCode" clearable></el-input>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="ActivationCodeDialog = false">取 消</el-button>
                <el-button type="primary" @click="SubmitActivationCode" :loading="btnLoading">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 激活账号end -->
        <!-- 修改昵称 -->
        <el-dialog
            title="修改昵称"
            :visible.sync="NicknameDialog"
            width="300px"
            center
            @close="clearInputVal"
        >
            <div>
                <div style="margin-bottom:15px;">
                    <span>当前昵称：</span>
                    <span>{{MemberInfo.nickname}}</span>
                </div>
                <el-input placeholder="请输入新昵称" v-model="NickNameVal" clearable maxlength="6"></el-input>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="NicknameDialog = false">取 消</el-button>
                <el-button type="primary" @click="checkNickName" :loading="btnLoading">确 定</el-button>
            </span>
        </el-dialog>
        <!-- 修改昵称 end -->
    </div>
</template>

<script>
let page = 1;
const pageSize = 15;
export default {
    props: {},
    data() {
        return {
            formulaTextarea: "", //验证结果
            formulaVerification: "", //需要验证的公式
            loading: false, //验证结果区loading true/false
            NicknameDialog: false, //修改昵称弹窗
            centerDialogVisible: false, //控制修改密码弹窗 true/false
            oldPwd: "", //修改密码，旧密码
            newPwd: "", //修改密码，新密码
            confirmPwd: "", //修改密码，确认新密码
            ActivationCode: "", //激活码
            NickNameVal: "", //用户输入的新昵称
            drawer: false, //控制侧边栏  true/false
            direction: "ltr", //控制侧边栏从哪个位置出现  rtl / ltr / ttb / btt
            Remarks: "", //收藏列表 修改备注input
            // popoverVisible: false, //
            copyTxt: "",
            cities: [], //下拉选择 验证彩种
            value: "", // 当前选择的彩种
            drawerValue: "", //抽屉中的select选择
            newsList: [], //公告内容
            gradeExpireTime: "0", //会员到期时间
            btnLoading: false,
            collectionListData: [], //收藏列表数据
            collectionListMeta: {
                total: 0
            },
            collectId: "",
            isCollection: false, //公式是否已收藏
            ActivationCodeDialog: false, //控制激活码弹窗
            fullWidth: document.documentElement.clientWidth,
            MemberInfo: "", //用户信息
            IsSelFormula: true, //是否为自己的收藏公式列表
            CourseListData: [], //功能说明列表
            IsFeatured: false //是否为精选公式
        };
    },
    computed: {
        optionLeft() {
            return {
                direction: 2,
                limitMoveNum: 1
            };
        }
    },
    created() {
        this.gradeExpireTime = sessionStorage.getItem("grade_expire_time");
        window.addEventListener("resize", this.handleResize);
        this.GetInstructionsType();
        this.GetSystem();
        this.GetUserInfo();
        this.getCourseList();
    },
    mounted() {},
    watch: {},
    methods: {
        dropDownClick(command) {
            console.log(command);
            window.open(this.CourseListData[command].url);
        },
        checkNickName() {
            this.$message.closeAll();
            if (this.NickNameVal === "") {
                this.$message.error("请输入昵称");
                return false;
            }
            var reg = /\s/;
            // console.log(reg.test(this.newPwd));
            if (reg.test(this.NickNameVal)) {
                this.$message.error("昵称不能包含空格");
                return false;
            }
            this.btnLoading = true;
            this.submitNickName();
        },
        submitNickName() {
            // 修改昵称
            let rsaStr = `nickname=${this.NickNameVal}`;
            this.$message.closeAll();
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.editNickName(rsaCode).then(res => {
                    // console.log(res);
                    this.btnLoading = false;
                    if (res.data.errno === "000") {
                        this.$message.success(res.data.errmsg);
                        this.MemberInfo = res.data.result.data;
                        this.NicknameDialog = false;
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        handleResize() {
            this.fullWidth = document.documentElement.clientWidth;
            // let str =
            //     window.innerWidth +
            //     "," +
            //     document.documentElement.clientWidth +
            //     "," +
            //     document.body.clientWidth;
            // alert(str);
        },
        toRecord() {
            // 前往开奖记录
            window.open("http://qn.mao5088.com/lottery/#/index");
        },
        VerificationOptions(val) {
            // 验证类型选项
            // console.log(val)
            this.drawerValue = val;
        },
        UpRemaker(index) {
            // 修改备注
            if (this.Remarks === "") {
                return false;
            }
            console.log(index);
            this.btnLoading = !this.btnLoading;
            this.EditRemak(this.collectionListData[index].id);
        },

        EditRemak(id) {
            // 需要修改的收藏列表id
            let rsaStr = `collection_id=${id}&remark=${this.Remarks}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http
                    .editRemak(rsaCode)
                    .then(res => {
                        this.$message.closeAll();
                        if (res.data.errno === "000") {
                            this.$message.success(res.data.errmsg);
                            this.GetCollectionList();
                        } else {
                            this.$message.error(res.data.errmsg);
                        }
                    })
                    .catch(err => {
                        console.log(err);
                    });
            });
        },
        // 收藏列表点击标题直接验证
        TestAndVerify(index) {
            // 判断账号是否激活
            if (this.gradeExpireTime == 0 || this.gradeExpireTime == "") {
                this.$message.closeAll();
                this.$message.error("账号未激活");
                return false;
            }
            this.loading = true;
            this.collectId = this.collectionListData[index].id;
            this.value = this.drawerValue;
            this.isCollection = true;
            this.IsFeatured ? this.GetFreeDetail() : this.GetCollectionDetail();
        },
        DrawerSelectChange(val) {
            console.log(val);
            page = 1;
            this.collectionListMeta.total = 0;
            this.btnLoading = !this.btnLoading;
            // this.value = val;
            this.IsFeatured ? this.GetFreeList() : this.GetCollectionList();
        },
        DelForks(val) {
            // console.log(val);
            // console.log(this.collectionListData[val].id);
            let rsaStr = `collection_id=${this.collectionListData[val].id}`;
            this.btnLoading = !this.btnLoading;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http
                    .deleteCollection(rsaCode)
                    .then(res => {
                        // this.btnLoading = false;
                        this.$message.closeAll();
                        if (res.data.errno === "000") {
                            this.$message.success(res.data.errmsg);
                            if (this.collectionListData.length > 1) {
                                this.GetCollectionList();
                            } else {
                                page = page == 1 ? 1 : Number(page - 1);
                                this.GetCollectionList();
                            }
                            // this.getMemberCollectionList();
                        } else {
                            this.$message.error(res.data.errmsg);
                        }
                    })
                    .catch(err => {
                        console.log(err);
                    });
            });
        },
        PaginationChange(val) {
            // console.log(val)
            page = val;
            this.IsFeatured ? this.GetFreeList() : this.GetCollectionList();
        },
        showDrawer(val) {
            // this.drawerValue = this.cities[0].id;
            this.IsFeatured = val === 3 ? true : false;
            page = 1;
            this.collectionListMeta.total = 0;
            this.btnLoading = !this.btnLoading;
            this.drawer = !this.drawer;
            val === 3 ? this.GetFreeList() : this.GetCollectionList();
        },
        FormulaEnter() {
            // 公式输入
            this.isCollection = false;
            // this.collectId = "";
        },
        VerifyCollect() {
            // 判断当前公式是否已收藏
            this.$message.closeAll();
            if (this.value === "") {
                this.$message.error("请选择验证类型");
                return false;
            }
            // if (this.isCollection) {
            //     this.$message.error("当前公式已收藏，请勿重复提交");
            //     return false;
            // }
            this.btnLoading = !this.btnLoading;
            this.PostCollectionFormula();
        },
        // 弹窗关闭清空input内容
        clearInputVal() {
            this.oldPwd = "";
            this.newPwd = "";
            this.confirmPwd = "";
            this.ActivationCode = "";
            this.btnLoading = false;
            this.NickNameVal = "";
        },
        Refresh() {
            // if (this.formulaVerification === "") {
            //     this.$message.closeAll();
            //     this.$message.error("请输入需要验证的公式");
            //     return false;
            // }
            // 刷新
            // this.btnLoading = !this.btnLoading;
            // this.loading = !this.loading;
            // this.VerificationFormula();
            this.formulaTextarea = "";
            this.formulaVerification = "";
            this.copyTxt = "";
            this.isCollection = false;
            this.collectId = "";
        },
        // 提交验证公式
        ReferFormulaVerification() {
            this.$message.closeAll();
            if (this.gradeExpireTime == 0 || this.gradeExpireTime == "") {
                this.$message.error("账号未激活");
                return false;
            }
            if (this.value === "") {
                this.$message.error("请选择验证类型");
                return false;
            }

            this.loading = !this.loading;
            this.formulaTextarea = "";
            this.VerificationFormula();
        },
        GetFreeDetail() {
            // 获取收藏公式详情
            let rsaStr = `id=${this.collectId}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.freeDetail(rsaCode).then(res => {
                    this.$message.closeAll();
                    // this.btnLoading = !this.btnLoading;
                    this.loading = false;
                    this.drawer = false;
                    if (res.data.errno === "000") {
                        this.formulaVerification = res.data.result.data.formula;
                        this.VerificationFormula();
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        GetFreeList() {
            // 获取收藏公式详情
            let rsaStr = `lotto_type=${this.drawerValue}&page=${page}&page_size=${pageSize}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.freeList(rsaCode).then(res => {
                    this.$message.closeAll();
                    this.btnLoading = false;
                    if (res.data.errno === "000") {
                        this.collectionListData = res.data.result.data;
                        this.collectionListMeta = res.data.result.meta;
                    } else {
                        this.collectionListData = [];
                        this.collectionListMeta.total = 0;
                        page = 1;
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        GetCollectionDetail() {
            // 获取收藏公式详情
            let rsaStr = `id=${this.collectId}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.getMemberCollectionDetail(rsaCode).then(res => {
                    this.$message.closeAll();
                    // this.btnLoading = !this.btnLoading;
                    this.loading = false;
                    this.drawer = false;
                    if (res.data.errno === "000") {
                        this.formulaVerification = res.data.result.data.formula;
                        this.VerificationFormula();
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        PostCollectionFormula() {
            // 收藏公式
            let params = {
                formula: this.formulaVerification,
                lotto_type: this.value
            };
            // console.log(params)
            this.http
                .collectionFormula(params)
                .then(res => {
                    this.$message.closeAll();
                    this.btnLoading = false;
                    if (res.data.errno === "000") {
                        this.$message.success(res.data.errmsg);
                        this.isCollection = true;
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        VerificationFormula() {
            // 验证公式
            let regStr = this.formulaVerification;
            regStr = regStr.replace(/\\-/gm, "_-");
            regStr = regStr.replace(/\\+/gm, "_");
            regStr = regStr.replace(/\\=/gm, "*");
            let params = {
                instructions: this.collectId == "" ? regStr : "",
                collect_id: this.IsFeatured ? "" : this.collectId,
                formula_id: this.IsFeatured ? this.collectId : "",
                lotto_type: this.value
            };
            // console.log(params);
            this.http.formula(params).then(res => {
                // console.log(res);
                this.loading = false;
                this.btnLoading = false;
                this.collectId = "";
                this.$message.closeAll();
                if (res.data.errno === "000") {
                    console.log(111);
                    this.isCollection = res.data.result.data.collected;
                    if (!res.data.result.data.kj_arr) {
                        let str =
                            res.data.result.data.kj_str_head +
                            "<br/>" +
                            res.data.result.data.kj_str.replace(
                                /\\n/gm,
                                "<br/>"
                            );
                        this.formulaTextarea = str;
                    } else {
                        let str = res.data.result.data.kj_str_head;
                        res.data.result.data.kj_arr.forEach(
                            (element, index) => {
                                // //console.log(element)
                                str = str + "<br/>" + element.kj;
                                // this.formulaTextarea = str;
                                if (
                                    index + 1 ===
                                    res.data.result.data.kj_arr.length
                                ) {
                                    str =
                                        str +
                                        "<br/>" +
                                        res.data.result.data.kj_str;
                                    this.formulaTextarea = str.replace(
                                        /\\n/gm,
                                        "<br/>"
                                    );
                                }
                            }
                        );
                        // //console.log(str)
                    }
                } else {
                    this.isCollection = false;
                    this.formulaTextarea = res.data.errmsg;
                    this.$message.error(res.data.errmsg);
                }
                setTimeout(() => {
                    this.copyTxt = this.$refs.copy.innerText;
                }, 1000);
            });
        },
        GetCollectionList() {
            // 获取收藏公式列表
            let rsaStr = `type=${!this.IsSelFormula ? 1 : 0}&lotto_type=${
                this.drawerValue
            }&page=${page}&page_size=${pageSize}`;
            // console.log(rsaStr);
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.collectionList(rsaCode).then(res => {
                    this.$message.closeAll();
                    this.btnLoading = false;
                    if (res.data.errno === "000") {
                        this.collectionListData = res.data.result.data;
                        this.collectionListMeta = res.data.result.meta;
                    } else {
                        this.collectionListData = [];
                        this.collectionListMeta.total = 0;
                        page = 1;
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        // 退出登录
        Logout() {
            this.btnLoading = !this.btnLoading;
            let rsaStr = `uuid=${sessionStorage.getItem("u")}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.postMemberLogout(rsaCode).then(res => {
                    this.$message.closeAll();
                    this.btnLoading = !this.btnLoading;
                    if (res.data.errno === "000") {
                        this.$message.success(res.data.errmsg);
                        sessionStorage.clear();
                        this.$router.push({
                            path: "/login"
                        });
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        // 提交新密码
        SubmitPassword() {
            var reg = /\s/;
            // console.log(reg.test(this.newPwd));
            this.$message.closeAll();
            if (reg.test(this.newPwd)) {
                this.$message.error("密码不能包含空格");
                return false;
            }
            if (this.oldPwd === "" || this.newPwd === "") {
                return false;
            }
            if (this.oldPwd !== "" && this.confirmPwd !== this.newPwd) {
                this.$message.error("两次密码不一致");
                return false;
            }
            this.btnLoading = !this.btnLoading;
            this.ResetPassword();
        },
        SubmitActivationCode() {
            this.$message.closeAll();
            if (this.ActivationCode === "") {
                this.$message.error("请输入激活码");
                return false;
            }
            this.btnLoading = !this.btnLoading;
            this.ActivateTheAccount();
        },
        // 验证结果区 到顶/底；
        stickyOrEnd() {
            let scrollHeight = this.$refs.copy.scrollHeight;
            // console.log(1111);
            console.log(this.$refs.copy.scrollTop);
            console.log(scrollHeight);

            if (this.$refs.copy.scrollTop > 0) {
                this.$refs.copy.scrollTop = 0;
            } else {
                this.$refs.copy.scrollTop = scrollHeight;
            }
        },
        ActivateTheAccount() {
            //   账号激活
            let rsaStr = `code=${this.ActivationCode}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.activate(rsaCode).then(res => {
                    this.$message.closeAll();
                    this.btnLoading = false;
                    this.GetUserInfo();
                    if (res.data.errno === "000") {
                        this.ActivationCodeDialog = false;
                        this.$message.success(res.data.errmsg);
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        // 修改密码
        ResetPassword() {
            let rsaStr = `old_pwd=${this.oldPwd}&pwd=${this.newPwd}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.postResetpwd(rsaCode).then(res => {
                    this.$message.closeAll();
                    this.btnLoading = false;
                    if (res.data.errno === "000") {
                        this.$message.success(res.data.errmsg);
                    } else {
                        this.$message.error(res.data.errmsg);
                    }
                });
            });
        },
        // 获取彩票类型
        GetInstructionsType() {
            let rsaStr = `timestamp=${Number(new Date())}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.instructionsType(rsaCode).then(res => {
                    if (res.data.errno === "000") {
                        this.value = res.data.result.data[0].id;
                        this.drawerValue = res.data.result.data[0].id;
                        this.cities = res.data.result.data;
                    } else {
                        this.cities = [];
                    }
                });
            });
        },
        // 获取系统信息
        GetSystem() {
            let rsaStr = `timestamp=${Number(new Date())}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.getSystem(rsaCode).then(res => {
                    // console.log(res);
                    if (res.data.errno === "000") {
                        this.newsList.push({
                            title: res.data.result.data.notice
                        });
                    } else {
                        this.newsList = [];
                    }
                });
            });
        },
        GetUserInfo() {
            // 获取用户信息
            let rsaStr = `uuid=${sessionStorage.getItem("u")}`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.getMemberInfo(rsaCode).then(res => {
                    if (res.data.errno === "000") {
                        // console.log(res);
                        this.gradeExpireTime =
                            res.data.result.data.grade_expire_time;
                        sessionStorage.setItem(
                            "grade_expire_time",
                            this.gradeExpireTime
                        );
                        this.MemberInfo = res.data.result.data;
                    } else {
                        this.MemberInfo = {};
                        // this.newsList = [];
                    }
                });
            });
        },
        getCourseList() {
            // 获取教程
            let rsaStr = `page=1&page_size=999`;
            this.$getCode(rsaStr).then(rsaCode => {
                this.http.courseList(rsaCode).then(res => {
                    if (res.data.errno === "000") {
                        // console.log(res);
                        this.CourseListData = res.data.result.data;
                    } else {
                        this.CourseListData = [];
                        // this.newsList = [];
                    }
                });
            });
        },
        onCopy() {
            // //console.log(this.$refs.copy.innerText)
            this.$message.closeAll();
            this.$message.success("复制成功");
        },
        onError() {
            this.$message.closeAll();
            this.$message.error("复制失败，请重试");
        }
    },
    components: {}
};
</script>
 
<style>
.el-header {
    background-color: #409eff;
    color: #333;
    /* text-align: center; */
    line-height: 60px;
}
.seamless-warp2 {
    overflow: hidden;
    height: 25px;
    width: 380px;
}
.seamless-warp2 ul.item {
    min-width: 700px;
}
.seamless-warp2 ul li {
    line-height: 25px;
    margin-right: 30px;
    color: #f56c6c;
}
.my_dropdown_menu::-webkit-scrollbar,
.forks_ul::-webkit-scrollbar {
    /*滚动条整体样式*/
    width: 5px;
    /*高宽分别对应横竖滚动条的尺寸*/
    height: 5px;
}

.my_dropdown_menu::-webkit-scrollbar-thumb,
.forks_ul::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius: 10px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    background: #409eff;
}

.my_dropdown_menu::-webkit-scrollbar-track,
.forks_ul::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    background: #fff;
}
.my_dropdown_menu {
    max-height: 300px;
    overflow-y: auto;
}
</style>

<style scoped lang="less">
@import url("./index.less");
</style>
